<?php
/**
 * 
 * 注册日志
 * @param $param
 * @param $uin
 */
function register_log($param,$uin)
{
    $db = new DB();
    $arr = array();
    foreach($param as $k=>$v){
    	$arr['`'.$k.'`']=$v;
    }
    $param = $arr;
    $string = $db->array_to_string($param,'insert');
    //$table = 'register_'.substr(md5($uin),0,1);        //注册日志：register_0(用md5（uin）第一位分表)
	$table = 'register_'.date('Ym');
    $sql = "insert into {$table}  {$string} ";
    $db->load_dsn('xx5_log');
    $db->query($sql);
}

/**
 * 
 * 登陆日志
 * @param $param
 * @param $uin
 */
function login_log($param,$uin)
{
    $db = new DB();
    $string = $db->array_to_string($param,'insert');
    $table = 'login_'.substr(md5($uin),0,1);        //注册日志：register_0(用md5（uin）第一位分表)
    $sql = "insert into {$table}  {$string} ";
    $db->load_dsn('xx5_log');
    $db->query($sql);
}

/**
 * 
 * 修改密码日志
 * @param $param
 * @param $uin
 */
function setpassword_log($param,$uin)
{
    $db = new DB();
    $string = $db->array_to_string($param,'insert');
    $table = 'setpassword_'.substr(md5($uin),0,1);        //注册日志：register_0(用md5（uin）第一位分表)
    $sql = "insert into {$table}  {$string} ";
    $db->load_dsn('xx5_log');
    $db->query($sql);
}

/**
 * 
 * 错误日志
 * @param $msg	错误信息
  * @param $app  业务号
 */
function _ErrorLog($msg = '', $app = 'XX5_PASSPORT') {
   
	$msg = array_to_string($msg);
	$msg = "[{$app}] $msg";
   	require_once(CORE_ROOT . '/public/library/common/logger/udp_logger.php');		
	$t = new Sky5Logger($app);	
	$t->log($msg);
}

/**
 * 
 * 数组转字符串
 * @param $param
 */
function array_to_string($param)
{
	if(!is_array($param))
	{
		return $param;
	}
	
	$string = var_export($param, true);
	$string = str_replace("\n", "", $string);
    return $string; 
}